# -*- coding:utf-8 -*-
# sqlalachemy 初始化建表
from sqlalchemy import Column, String, Integer
from sqlalchemy.ext.declarative import declarative_base

# 创建对象的基类:
Base = declarative_base()


# 作废
class BaseZhihuUser(Base):
    """
    知乎用户基本表
    """

    def __init__(self, userName, userUrl, userPhoto):
        self.userName = userName
        self.userUrl = userUrl
        self.userPhoto = userPhoto

    __tablename__ = "basezhihuuser"

    userName = Column(String(20), primary_key=True)
    userUrl = Column(String(100), default="")
    userPhoto = Column(String(100), default="")


class UserAboutUrls(Base):
    """
    知乎about详细页
    """

    def __init__(self, abouturls):
        self.abouturls = abouturls

    __tablename__ = "abouturls"

    abouturl = Column(String(100), primary_key=True)


class DetailZhihuUser(Base):
    """
    知乎用户详细信息表
    """

    def __init__(self, zhi_id, nick, location, bussiness, sex, vote, thanks, fav, share,
                 employment, position, edu, edu_extra, followees, followeers,
                 column, topics, weibo, topics_list):
        self.zhi_id = zhi_id
        self.nick = nick
        self.location = location
        self.bussiness = bussiness
        self.sex = sex
        self.vote = vote
        self.thanks = thanks
        self.fav = fav
        self.share = share
        self.employment = employment
        self.position = position
        self.edu = edu
        self.edu_extra = edu_extra
        self.followees = followees
        self.followeers = followeers
        self.column = column
        self.topics = topics
        self.weibo = weibo
        self.topics_list = topics_list

    __tablename__ = 'zhihu'

    zhi_id = Column(String(100), default="")
    nick = Column(String(100), default="")
    location = Column(String(50), default="")
    bussiness = Column(String(50), default="")
    sex = Column(String(10), default="")
    vote = Column(Integer, default=0)
    thanks = Column(Integer, default=0)
    fav = Column(Integer, default=0)
    share = Column(Integer, default=0)
    employment = Column(String(50), default="")
    position = Column(String(50), default="")
    edu = Column(String(50), default="")
    edu_extra = Column(String(50), default="")
    followees = Column(Integer, default=0)
    followeers = Column(Integer, default=0)
    column = Column(String(10), default="")
    topics = Column(String(10), default="")
    weibo = Column(String(50), default="")
    topics_list = Column(String(500), default="")


# 用户关注兴趣点
class InterestZhihuUser(Base):
    def __init__(self, zhi_id, intest):
        self.zhi_id = zhi_id
        self.intest = intest

    __tablename__ = 'zhihu_intest'

    id = Column("id", Integer, primary_key=True)
    zhi_id = Column("zhi_id", String(100), default="")
    interest = Column("interest", String(1000), default="")


# 关系
class Relationship(Base):
    def __init__(self, zhi_id, followers, followees):
        self.zhi_id = zhi_id
        self.followers = followers
        self.followees = followees

    __tablename__ = 'zhihu_relationship'
    id = Column("id", Integer, primary_key=True)
    zhi_id = Column("zhi_id", String(100), default="")
    followers = Column("followers", String(1000), default="")
    followees = Column("followees", String(1000), default="")
